package com.itheima.mp.controller;


import com.itheima.mp.domain.po.Address;
import com.itheima.mp.service.IAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author itheima
 * @since 2025-05-26
 */
@Api(tags = "地址管理")
@RestController
@RequestMapping("/address")
@RequiredArgsConstructor
public class AddressController {

    private final IAddressService addressService;

    @ApiOperation("根据ID删除地址")
    @DeleteMapping("/{id}")
    public boolean deleteAddressById(@PathVariable Long id) {
        return addressService.removeById(id);
    }

    @ApiOperation("根据ID查询地址")
    @GetMapping("/{id}")
    public Address getAddressById(@PathVariable Long id) {
        return addressService.getById(id);
    }
}
